package com.mrzhou.file.controller;

import com.mrzhou.file.util.PdfUtil;
import com.mrzhou.web.util.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;

@RestController
@RequestMapping("/test")
@Api(tags = ("测试接口"))
public class TestController {

    @GetMapping("/download-pdf")
    @ApiOperation("下载系统生成的pdf")
    public void downloadPdf(HttpServletResponse response) {
        String[] param = {"张康康", "15332652546", "机构采购系统", "VCN0024259", "机构采购系统", "张康康", "隆冬寒梅", "呵呵呵大哒", "呵呵呵大哒", "2020-07-20", "2020-07-20"};
        String path = PdfUtil.htmlToPdf(PdfUtil.handlerHtmlTemplate(param, "template/auth.html"));
        FileUtil.fileUploadStream(new File(path), response);
    }
}
